import Vue from 'vue'; //引入vue插件

//引入vue-router插件，在项目的根目录下运行 cnpm i vue-router --save-dev 安装插件。
import Router from 'vue-router';
Vue.use(Router);

//引入页面模板
import home from '../views/home.vue';
import recommend from '../views/recommend.vue';
import ranking from '../views/ranking.vue';
import search from '../views/search.vue';
import list from '../views/list.vue';
import singer from '../views/singer.vue';
import singer_songs from '../views/singer_songs.vue';


//配置组件的路径和注册
//const表示不可被修改的常量
const routes = [{
		path: "/",
		redirect: "home",
	},
	{
		path: "/home", //默认路由。这里默认渲染home模板。
		name: "home",
		component: home,
		children: [{
				path: "/",
				redirect: "recommend",
			},
			{
				path: "recommend",
				name: "recommend",
				component: recommend,
			},
			{
				path: "ranking",
				name: "ranking",
				component: ranking,
			},
			{
				path: "singer",
				name: "singer",
				component: singer,
			},
			{
				path: "search",
				name: "search",
				component: search,
			},
		]
	},
	{
		path: "/list",
		name: "list",
		component: list,
	},
	{
		path: "/singer_songs",
		name: "singer_songs",
		component: singer_songs,
	},
];

//创建vue-router的实例
//注意：Router对象的路由配置，属性名为routes，切记不要改动。
const router = new Router({
	routes: routes,
});
//输出给其他文件使用router对象
export default router;